package com.czy.basecommon.utils.tools;

import android.app.ActivityManager;
import android.content.Context;
import android.util.Log;

import com.czy.basecommon.utils.global.ItrackApp;


/**
 * @author Jake Han
 */
public class LogTool {
    public static boolean isDebug = true;
    public static final String TAG = "LogTool";

    private LogTool(){
        throw new UnsupportedOperationException("cannot be instantiated");
    }

    public static void i(String tag, String msg)
    {
        if (isDebug)
            Log.i(tag, msg);
    }

    public static void d(String tag, String msg)
    {
        if (isDebug)
            Log.i(tag, msg);
    }

    public static void e(String tag, String msg)
    {
        if (isDebug)
            Log.i(tag, msg);
    }

    public static void v(String tag, String msg)
    {
        if (isDebug)
            Log.i(tag, msg);
    }

    public static void w(String tag, String msg){
        if(isDebug)
            Log.v(tag,msg);
    }

    public static String getActivityTag(){
        ActivityManager activityManager=(ActivityManager) ItrackApp.context
                .getSystemService(Context.ACTIVITY_SERVICE);

        String tag =  activityManager.getRunningTasks(1)
                .get(0).topActivity.getShortClassName();
        return tag.replace(".activity.","");
    }
}
